#pragma once

#include "Goal.h"

namespace Tmpl {

typedef std::deque<Goal*> SubGoalList;
class GoalComposite : public Goal
{
public:
	GoalComposite(Entity* owner) : Goal(owner){}
	virtual ~GoalComposite(){RemoveAllSubGoals();}

	void AddSubgoal(Goal* goal);
	char ProcessSubGoals(char threadId);
	void RemoveAllSubGoals();
	bool ForwardMessageToFrontMostSubgoal(const MsgData& msg);

	virtual bool HandleMessage(const MsgData& msg){ return ForwardMessageToFrontMostSubgoal(msg); }
	virtual void Render() const;

	bool isComplete()const{return mStatus == GOALSTATUS_COMPLETED;} 
	bool isActive()const{return mStatus == GOALSTATUS_ACTIVE;}
	bool isInactive()const{return mStatus == GOALSTATUS_INACTIVE;}
	bool hasFailed()const{return mStatus == GOALSTATUS_FAILED;}

protected:
	SubGoalList mSubGoals;
};

}